<?php
$this->headTitle($this->translator('user_edit_permission_title'));
?>
<style>
    .caption{
		font-weight: bold;
		background: #BCBBB9;
	}
	
	table{
		border-top:none;
		border-bottom:none;
	}
	.list table{
		width: 100%;
		border-top: 0px;
		border-bottom: 0px;
	}
	.list .caption td{
		font-weight: bold;
		background: #BCBBB9;
	}
	.list tr.caption:hover td{
		font-weight: bold;
		background: #BCBBB9;
	}
	.list tbody tr:hover td{
		background: #EFEDED;
	} 
    
    .evaluation_label{
    	display: block; 
    	float: left; 
    	line-height: 15px;
    	margin-right: 20px;
		width: 80px; 
    }
</style>
<?php if($this->enterprise): ?>
<div class="t_bizprofile_permission">
    <h2><?php echo $this->translator('user_edit_permission_title'); ?></h2>
    <div class="message"><?php echo $this->flashMessenger(); ?></div>
    <form method="post" action="" id="editPermissionForm">
        <table width="100%" cellpadding="0" cellspacing="0" class="list">
        <tr class="caption">
	        <td class="item" style="width: 20%"><?php echo $this->translator('enterprise_visibility_prermission_name');?></td>
	        <?php foreach ($this->roles as $role): ?>
	            <td class="item" style="width: 20%"><?php echo $this->translator('enterprise_visibility_'.$role->name);?></td>
	        <?php endforeach; ?>
        </tr>
        <tr> <!-- Xem bai viết -->
            <td><?php echo $this->translator('blog_permission'); ?></td>
            <?php foreach ($this->permissions as $permission): ?>
                <td><input type="checkbox" class="checkbox" name="blog_permission_<?php echo $permission->user_entity ?>"
                        id="blog_permission_<?php echo $permission->user_entity ?>"
                        <?php if($permission->blog_permission): ?>checked="checked"<?php endif; ?> /></td>
            <?php endforeach; ?>
        </tr>
        <tr>
            <td><?php echo $this->translator('media_permission'); ?></td>
            <?php foreach ($this->permissions as $permission): ?>
                <td><input type="checkbox" class="checkbox" name="media_permission_<?php echo $permission->user_entity ?>"
                        id="media_permission_<?php echo $permission->user_entity ?>"
                        <?php if($permission->media_permission): ?>checked="checked"<?php endif; ?> /></td>
            <?php endforeach; ?>
        </tr>
        <tr>
            <td><?php echo $this->translator('partner_permission'); ?></td>
            <?php foreach ($this->permissions as $permission): ?>
                <td><input type="checkbox" class="checkbox" name="partner_permission_<?php echo $permission->user_entity ?>"
                        id="partner_permission_<?php echo $permission->user_entity ?>"
                        <?php if($permission->partner_permission): ?>checked="checked"<?php endif; ?> /></td>
            <?php endforeach; ?>
        </tr>
        <tr><!-- Gửi tin nhắn -->
            <td><?php echo $this->translator('messaging_permission'); ?></td>
            <?php $i=0; foreach ($this->permissions as $permission): ?>
                <td><input type="checkbox" class="checkbox" name="messaging_permission_<?php echo $permission->user_entity ?>"
                        id="messaging_permission_<?php echo $permission->user_entity ?>"
                        <?php if($permission->messaging_permission): ?>checked="checked"<?php endif; ?>
                        <?php if($i==0) {echo "style='visibility:hidden;'";} $i++; ?> /></td>
                        <?php // User chưa login, ko được phép gửi tin nhắn  ?>
            <?php endforeach; ?>
        </tr>

        <?php foreach ($this->general_info as $key => $value) :?>
            <tr>
                <td><?php echo $this->translator($key); ?></td>
                <?php foreach ($this->permissions as $permission): ?>
                    <?php $infos = unserialize($permission->general_info); ?>
                    <td><input class="checkbox" type="checkbox" name="general_info_<?php echo $key; ?>_<?php echo $permission->user_entity ?>"
                            id="general_info_<?php echo $key; ?>_<?php echo $permission->user_entity ?>"
                            <?php if($infos[$key]): ?>checked="checked"<?php endif; ?>
                            /></td>
                <?php endforeach;?>
            </tr>
        <?php endforeach; ?>

        <?php foreach ($this->enterprise_info as $key => $value) :?>
            <tr>
                <td><?php echo $this->translator('enterprise_info_'.($key + 1));?></td>
                <?php foreach ($this->permissions as $permission): ?>
                    <?php $infos = unserialize($permission->enterprise_info); ?>
                    <td><input class="checkbox" type="checkbox" name="enterprise_info_<?php echo $key; ?>_<?php echo $permission->user_entity ?>"
                            id="enterprise_info_<?php echo $key; ?>_<?php echo $permission->user_entity ?>"
                            <?php if($infos[$key]): ?>checked="checked"<?php endif; ?>
                            /></td>
                <?php endforeach;?>
            </tr>
        <?php endforeach; ?>
        </table>
        <div class="button">
            <label>&nbsp;</label>
            <?php echo $this->tokenElement; ?>
            <button type="submit"><span><?php echo $this->translator('save'); ?></span></button>
        </div>
    </form>
</div>
<?php endif; ?>
